import org.ww.bean.Person;
import org.ww.config.MainConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;

public class MainClass {
    public static void main(String[] args) {
        //使用xml文件获取bean
//        ApplicationContext application = new ClassPathXmlApplicationContext("beans.xml");
//        Person person = (Person) application.getBean("person");
//        System.out.println(person);
        //使用config配置文件获取bean
        ApplicationContext application = new AnnotationConfigApplicationContext(MainConfig.class);
        Person bean = application.getBean(Person.class);
        System.out.println(bean);
        String[] names = application.getBeanNamesForType(Person.class);
        System.out.println(Arrays.toString(names));
    }
}
